//
//  SafeThreeTypePeopleVC.m
//  Estate
//
//  Created by wangdongdong on 2017/9/29.
//  Copyright © 2017年 ttsx. All rights reserved.
//

#import "ConstructionSuperintendentModel2.h"
#import "ThreeTypePeople.h"
#import "ConstructionSuperintendentModel.h"
#import "SafeThreePeopleCell2.h"
#import "SafeThreePeopleCell.h"

#import "SafeThreeTypePeopleVC.h"

@interface SafeThreeTypePeopleVC ()<UITableViewDelegate, UITableViewDataSource>

// 表格
@property (strong, nonatomic) TPKeyboardAvoidingTableView *tableView;

// 项目负责人数据
@property (strong, nonatomic) NSMutableArray *projectLeaderArr;

// 专职安全员数据
@property (strong, nonatomic) NSMutableArray *saferArray;

// 施工单位ID
@property (copy, nonatomic) NSString *constructionUnitID;

// 记录总的信息模型
@property (strong, nonatomic) ConstructionSuperintendentModel2 *model2;


@end


@implementation SafeThreeTypePeopleVC

// 记录总的信息模型
- (ConstructionSuperintendentModel2 *)model2 {
    if (!_model2) {
        _model2 = [[ConstructionSuperintendentModel2 alloc] init];
    }
    return _model2;
}

// 项目负责人数据
- (NSMutableArray *)projectLeaderArr {
    if (!_projectLeaderArr) {
        _projectLeaderArr = [NSMutableArray array];
    }
    return _projectLeaderArr;
}

// 专职安全员数据
- (NSMutableArray *)saferArray {
    if (!_saferArray) {
        _saferArray = [NSMutableArray array];
    }
    return _saferArray;
}

- (TPKeyboardAvoidingTableView *)tableView {
    if (_tableView == nil) {
        _tableView = [[TPKeyboardAvoidingTableView alloc]initWithFrame:CGRectMake(0, 0, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT - 188) style:UITableViewStyleGrouped];
        _tableView.backgroundColor = UIColorFromRGB(0xf2f2f2);
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.bounces = NO;
        _tableView.showsVerticalScrollIndicator = NO;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        
        [_tableView registerNib:[UINib nibWithNibName:@"SafeThreePeopleCell" bundle:nil] forCellReuseIdentifier:@"threeCell"];
        [_tableView registerNib:[UINib nibWithNibName:@"SafeThreePeopleCell2" bundle:nil] forCellReuseIdentifier:@"threeCell2"];
    }
    return _tableView;
}

- (void)viewDidLoad {
    [super viewDidLoad];

    // 刷新表格
    [self refreshTable:nil];
    // 添加通知(刷新页面)
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshTable:) name:@"refreshCheckInformation" object:nil];
}

- (void)viewWillAppear:(BOOL)animated {
    // 添加通知(暂存/保存检查信息)
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(saveSecurityCheckInformation:) name:@"saveSafeCheck" object:nil];
}

- (void)viewWillDisappear:(BOOL)animated {
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"saveSafeCheck" object:nil];
}

#pragma mark - 暂存/保存 安全检查信息
- (void)saveSecurityCheckInformation:(NSNotification *)notification {
    // 接收通知来的信息
    NSDictionary *parameDic = [notification object];
    // 项目负责人信息为空
    if (self.projectLeaderArr.count == 0) {
        ConstructionSuperintendentModel *model = [[ConstructionSuperintendentModel alloc] init];
        [self.projectLeaderArr addObject:model];
    }
    // 项目安全员信息为空
    if (self.saferArray.count == 0) {
        ConstructionSuperintendentModel *model = [[ConstructionSuperintendentModel alloc] init];
        [self.saferArray addObject:model];
    }
    // 插入数据(项目负责人)
    [self insertSafeConstruct:parameDic withArr:self.projectLeaderArr withType:@"TOTAL_USER_TYPE_01"];
    // 插入数据(项目安全员)
    [self insertSafeConstruct:parameDic withArr:self.saferArray withType:@"TOTAL_USER_TYPE_02"];
}

// 插入数据(施工三类人员表)
- (void)insertSafeConstruct:(NSDictionary *)parameDic withArr:(NSArray *) insertArr withType:(NSString *)typeStr {
    FMDatabase *db = [FMDatabase databaseWithPath:DEF_DB_DATABASEPATH];
    DBHelper *dbhelper = [DBHelper help];

    for (ConstructionSuperintendentModel *model in insertArr) {
        // 字段及对应值
        NSDictionary *pragameDic = [NSDictionary dictionary];
        pragameDic = @{
                       @"ID":DEFISNUL([NSUUID UUID].UUIDString),
                       @"PRO_ID":DEF_PERSISTENT_GET_OBJECT(@"proid"),
                       @"BASIC_RECORD_ID":DEFISNUL(parameDic[@"safeBaseID"]),
                       @"RECORD_USER":DEFISNUL(DEF_PERSISTENT_GET_OBJECT(@"userid")),
                       @"RECORD_TYPE":DEFISNUL(@"SAFE_RECORD_02"),
                       @"RECORD_TITLE":DEFISNUL(parameDic[@"title"]),
                       @"RECORD_NUMBER":DEFISNUL(parameDic[@"recordNumber"]),
                       @"TOTAL_USER_TYPE":DEFISNUL(typeStr),
                       @"DANGER_FACTOR":DEFISNUL(model.peopleRole),
                       @"REALNAME":DEFISNUL(model.realName),
                       @"USERNAME":DEFISNUL(model.userName),
                       @"USER_TITLE":DEFISNUL(model.titleName),
                       @"IS_ON_POSITION":DEFISNUL(model.workState),
                       @"IS_DO_CHECK":DEFISNUL(model.certificateInspection),
                       @"IS_EFFECITIVE":DEFISNUL(model.certificateValid),
                       @"IS_MEET_REQUIRE":DEFISNUL(model.appraise),
                       @"OTHER_NOTE":DEFISNUL(model.otherInstruction),
                       @"PRO_ON_DUTY_CNT":DEFISNUL(self.model2.proActualcount),
                       @"PRO_FIT_CNT":DEFISNUL(self.model2.inPeopleCount),
                       @"PRO_FIT_RATE":DEFISNUL(self.model2.coincidenceRate),
                       @"PRO_IS_MEET_REQUIRE":DEFISNUL(self.model2.isMeetRequire),
                       @"SAFE_ONDUTYCNT":DEFISNUL(self.model2.safeProActualcount),
                       @"SAFE_FIT_CNT":DEFISNUL(self.model2.safeInPeopleCount),
                       @"SAFE_FIT_RATE":DEFISNUL(self.model2.safeCoincidenceRate),
                       @"SAFE_IS_MEET_REQUIRE":DEFISNUL(self.model2.safeIsMeetRequire),
                       @"EXTEND_INFO":@"",
                       @"CREATE_USER_NAME":DEF_PERSISTENT_GET_OBJECT(@"loginuser"),
                       @"CREATE_TIME":DEFISNUL([LSUtility nowTime]),
                       @"CREATE_IP":DEFISNUL([LSUtility getIPAddress]),
                       @"MODIFY_USER_NAME":@"",
                       @"MODIFY_TIME":@"",
                       @"MODIFY_IP":@"",
                       @"LOCAL_MODIFY_USER_NAME":@"",
                       @"LOCAL_MODIFY_TIME":@"",
                       @"LOCAL_MODIFY_STATE":@"ADD",
                       };

        BOOL isAdd = [dbhelper DataBase:db insertKeyValues:pragameDic intoTable:SAFE_CONSTRUCT];
        if (isAdd) {
            NSLog(@"添加安全施工三类人员成功");

        } else {
            NSLog(@"添加安全施工三类人员失败");
        }
    }
    
    // 刷新安全列表页
    [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshSafeList" object:nil];
    [self.navigationController popViewControllerAnimated:YES];
}

// 刷新表格
- (void)refreshTable:(NSNotification *)notification {
    // 初始化数据源
    [self.projectLeaderArr removeAllObjects];
    [self.saferArray removeAllObjects];

    self.constructionUnitID = [notification object];
    if (self.constructionUnitID) {
        // 查找项目负责人
        [self checkProjectLeader];
        // 查找专职安全员
        [self checkSaferData];
    }
    
    if (_tableView) {
        [self.tableView reloadData];

    } else {
        [self.view addSubview:self.tableView];
    }
}

// 查找项目负责人数据
- (void)checkProjectLeader {
    NSString *sqlStr = [NSString stringWithFormat:@"SELECT *, date(EXPIRE_TIME) FROM PROJECT_USER WHERE UNIT_ID = '%@' AND USER_TYPE IN ('CONSTRACT_01', 'CONSTRACT_02', 'CONSTRACT_03', 'CONSTRACT_09')", self.constructionUnitID];
    FMDatabase *db = [FMDatabase databaseWithPath:DEF_DB_DATABASEPATH];
    [db open];
    
    FMResultSet *result = [db executeQuery:sqlStr];
    while ([result next]) {
        // 职位
        ConstructionSuperintendentModel *model = [[ConstructionSuperintendentModel alloc] init];
        NSString *userType = [result stringForColumn:@"USER_TYPE"];
         model.peopleRole = userType;
        // 用户ID
        NSString *userID = [result stringForColumn:@"USER_ID"];
        // 用户真实姓名
        model.realName = [LSUtility getuserIdByUserName:userID][@"REAL_NAME"];
        // 用户名
        model.userName = [LSUtility getuserIdByUserName:userID][@"USER_NAME"];
        
        // 职称
        model.titleName = [result stringForColumn:@"TITLE_NAME"];
        
        // 证书是否有效
        NSString *timeStr = [result stringForColumn:@"date(EXPIRE_TIME)"];
        if (timeStr && ![timeStr isEqualToString:@""]) {
            // 获取当下日期
            NSDate *currentDate = [NSDate date];
            NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
            [formatter setDateFormat:@"yyyy-MM-dd"];
            NSString *currentDateStr = [formatter stringFromDate:currentDate];
            int cha = [LSUtility compareLocalDate:timeStr withServerDate:currentDateStr];
            if (cha == 1) {
                model.certificateValid = @"0";
                
            } else {
                model.certificateValid = @"1";
            }
        } else {
            model.certificateValid = @"1";
        }
        [self.projectLeaderArr addObject:model];
    }
    [db close];
}

// 查找专职安全员数据
- (void)checkSaferData {
    // 项目单位ID
    NSString *sqlStr = [NSString stringWithFormat:@"SELECT *, date(EXPIRE_TIME) FROM PROJECT_USER WHERE UNIT_ID = '%@' AND USER_TYPE = 'CONSTRACT_05'", self.constructionUnitID];
    FMDatabase *db = [FMDatabase databaseWithPath:DEF_DB_DATABASEPATH];
    [db open];
    
    FMResultSet *result = [db executeQuery:sqlStr];
    while ([result next]) {
        // 职位
        ConstructionSuperintendentModel *model = [[ConstructionSuperintendentModel alloc] init];
        
        // 用户ID
        NSString *userID = [result stringForColumn:@"USER_ID"];
        // 用户真实姓名
        model.realName = [LSUtility getuserIdByUserName:userID][@"REAL_NAME"];
        // 用户名
        model.userName = [LSUtility getuserIdByUserName:userID][@"USER_NAME"];
        // 角色
        model.peopleRole = @"CONSTRACT_05";
        // 职称
        model.titleName = [result stringForColumn:@"TITLE_NAME"];
        // 证书是否有效
        NSString *timeStr = [result stringForColumn:@"date(EXPIRE_TIME)"];
        if (timeStr && ![timeStr isEqualToString:@""]) {
            // 获取当下日期
            NSDate *currentDate = [NSDate date];
            NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
            [formatter setDateFormat:@"yyyy-MM-dd"];
            NSString *currentDateStr = [formatter stringFromDate:currentDate];
            int cha = [LSUtility compareLocalDate:timeStr withServerDate:currentDateStr];
            if (cha == 1) {
                model.certificateValid = @"0";
                
            } else {
                model.certificateValid = @"1";
            }
        } else {
            model.certificateValid = @"1";
        }
        [self.saferArray addObject:model];
    }
    [db close];
}

#pragma MARK - UITableViewDelegate, UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return self.projectLeaderArr.count + self.saferArray.count + 2;
}

// 控制表头分组表头高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0 || section == self.projectLeaderArr.count+1) {
        return 40;
    }
    return 10;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { 
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, DEF_SCREEN_WIDTH, 40)];
    UILabel *nameLabel = [[UILabel alloc] init];
    [headerView addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(headerView.mas_centerX);
        make.centerY.equalTo(headerView.mas_centerY);
    }];
    nameLabel.textColor = subtitleColor;
    nameLabel.text = @"项目负责人";
    [nameLabel sizeToFit];
    // 分割线
    UIView *lineView1 = [[UIView alloc] init];
    lineView1.backgroundColor = separator_Color;
    [headerView addSubview:lineView1];
    [lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(headerView.mas_centerY);
        make.left.offset(30);
        make.right.equalTo(nameLabel.mas_left).offset(-10);
        make.height.offset(1);
    }];
    
    UIView *lineView2 = [[UIView alloc] init];
    lineView2.backgroundColor = separator_Color;
    [headerView addSubview:lineView2];
    [lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(headerView.mas_centerY);
        make.left.equalTo(nameLabel.mas_right).offset(10);
        make.right.offset(-30);
        make.height.offset(1);
    }];

    if (section == 0) {
        return headerView;

    } else if (section == self.projectLeaderArr.count+1) {
        nameLabel.text = @"专职安全员";
        return headerView;

    } else {
        return nil;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.01;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    UIView *view = [[UIView alloc] init];
    return view;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSInteger section = indexPath.section;
    
    if (section < self.projectLeaderArr.count+self.saferArray.count+1 && section != self.projectLeaderArr.count) {
        return 250;
        
    } else {
        return 210;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSInteger section = indexPath.section;
    // 数据
    ConstructionSuperintendentModel *model = [[ConstructionSuperintendentModel alloc] init];
    
    if (section < self.projectLeaderArr.count+self.saferArray.count+1 && section != self.projectLeaderArr.count) {
        // 数据模型
        if (section < self.projectLeaderArr.count) {
            model = self.projectLeaderArr[section];
            
        } else if (section > self.projectLeaderArr.count && section < (self.projectLeaderArr.count+self.saferArray.count+1)) {
            model = self.saferArray[section-self.projectLeaderArr.count-1];
        }
        
        SafeThreePeopleCell *threeCell = [tableView dequeueReusableCellWithIdentifier:@"threeCell" forIndexPath:indexPath];
        threeCell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        // 真实姓名
        threeCell.nameLabel.text = model.realName;
        // 用户名
        model.userName = model.userName;
        // 职位
        if ([model.peopleRole isEqualToString:@"CONSTRACT_01"]) {
            threeCell.positionLabel.text = @"项目经理";
        } else if ([model.peopleRole isEqualToString:@"CONSTRACT_02"]) {
            threeCell.positionLabel.text = @"技术负责人";
        } else if ([model.peopleRole isEqualToString:@"CONSTRACT_03"]) {
            threeCell.positionLabel.text = @"安全负责人";
        } else if ([model.peopleRole isEqualToString:@"CONSTRACT_09"]) {
            threeCell.positionLabel.text = @"项目副经理";
        }else if ([model.peopleRole isEqualToString:@"CONSTRACT_05"]) {
            threeCell.positionLabel.text = @"专职安全员";
        }
        // 职称
        if (model.titleName && ![model.titleName isEqualToString:@""]) {
            threeCell.titleLabel.text = [NSString stringWithFormat:@"职称:%@", model.titleName];
        }
        // 到岗状态
        if (!model.workState) {
            model.workState = @"0";
        }
        if ([model.workState isEqualToString:@"1"]) {
            threeCell.state.selected = YES;
        } else {
            threeCell.state.selected = NO;
        }
        
        threeCell.stateBlock = ^(NSString *str) {
            model.workState = str;
        };
        
        // 证书是否查验
        if (!model.certificateInspection) {
            model.certificateInspection = @"1";
        }
        if ([model.certificateInspection isEqualToString:@"1"]) {
            threeCell.certificateInspectionSwitch.on = YES;
            
        } else {
            threeCell.certificateInspectionSwitch.on = NO;
        }
        // 数据回传
        threeCell.certificateInspectionBlock = ^(NSString *str) {
            model.certificateInspection = str;
        };
        
        // 证书是否有效
        if (!model.certificateInspection) {
            model.certificateInspection = @"1";
        }
        if ([model.certificateValid isEqualToString:@"1"]) {
            threeCell.certificateValidSwitch.on = YES;
            
        } else {
            threeCell.certificateValidSwitch.on = NO;
        }
        // 数据回传
        threeCell.certificateValidBlock = ^(NSString *str) {
            model.certificateValid = str;
        };
        
        // 评价(是否符合要求)
        if (!model.appraise) {
            model.appraise = @"1";
        }
        if ([model.appraise isEqualToString:@"1"]) {
            threeCell.appraiseSwitch.on = YES;
            
        } else {
            threeCell.appraiseSwitch.on = NO;
        }
        // 评价回传
        threeCell.appraiseBlock = ^(NSString *str) {
            model.appraise = str;
        };
        
        // 其他说明
        threeCell.otherText.placeholder = @"请输入其他说明";
        threeCell.otherText.text = DEFISNUL(model.otherInstruction);
        // 数据回传
        threeCell.otherTextBlock = ^(NSString *str) {
            model.otherInstruction = str;
        };
        return threeCell;
        
    } else {
        SafeThreePeopleCell2 *threeCell2 = [tableView dequeueReusableCellWithIdentifier:@"threeCell2" forIndexPath:indexPath];
        threeCell2.selectionStyle = UITableViewCellSelectionStyleNone;
        __weak __typeof(threeCell2) weakCell2 = threeCell2;

        // 项目负责人
        if (section == self.projectLeaderArr.count) {
            
            // 项目实际人数
            threeCell2.actualPeopleNumberField.text = DEFISNUL(self.model2.proActualcount);
            threeCell2.actualPeopleNumberBlock = ^(NSString *str) {
                self.model2.proActualcount = str;
                // 更新符合率
                if (self.model2.inPeopleCount && ![self.model2.inPeopleCount isEqualToString:@""] && self.model2.proActualcount && ![self.model2.proActualcount isEqualToString:@""]) {
                    
                    double rate = [self.model2.inPeopleCount doubleValue] / [self.model2.proActualcount doubleValue];
                    self.model2.coincidenceRate = [NSString stringWithFormat:@"%.2f", rate];
                    NSString *str = [NSString stringWithFormat:@"%.2f%%", rate*100];
                    weakCell2.coincidenceRateLabel2.text =  DEFISNUL(str);
                    
                }
            };
            
            // 符合人数
            threeCell2.complyNumberField.text = DEFISNUL(self.model2.inPeopleCount);
            threeCell2.complyNumberBlock = ^(NSString *str) {
                self.model2.inPeopleCount = str;
                
                // 更新符合率
                if (self.model2.inPeopleCount && ![self.model2.inPeopleCount isEqualToString:@""] && self.model2.proActualcount && ![self.model2.proActualcount isEqualToString:@""]) {
                    
                    double rate = [self.model2.inPeopleCount doubleValue] / [self.model2.proActualcount doubleValue] ;
              
                    self.model2.coincidenceRate = [NSString stringWithFormat:@"%.2f", rate];
                    NSString *str = [NSString stringWithFormat:@"%.2f%%", rate*100];
                    weakCell2.coincidenceRateLabel2.text =  DEFISNUL(str);
                }
            };
            
            // 符合率
            if (!self.model2.coincidenceRate) {
                self.model2.coincidenceRate = @"0";
            }
            
            double rate = [self.model2.coincidenceRate doubleValue];
            NSString *str = [NSString stringWithFormat:@"%.2f%%", rate*100];
            threeCell2.coincidenceRateLabel2.text = DEFISNUL(str);
            
            // 配备符合要求
            // 默认为1
            if (!self.model2.isMeetRequire) {
                self.model2.isMeetRequire = @"1";
            }
            if ([self.model2.isMeetRequire isEqualToString:@"1"]) {
                threeCell2.meetRequireSwitch.on = YES;

            } else {
                threeCell2.meetRequireSwitch.on = NO;
            }
            threeCell2.meetRequireBlock = ^(NSString *str) {
                self.model2.isMeetRequire = str;
            };
            
        // 项目安全员
        } else if (section == self.projectLeaderArr.count+self.saferArray.count+1) {
            // 项目实际人数(安全员)
            threeCell2.actualPeopleNumberField.text = DEFISNUL(self.model2.safeProActualcount);
            threeCell2.actualPeopleNumberBlock = ^(NSString *str) {
                self.model2.safeProActualcount = str;
                
                // 更新符合率
                if (self.model2.safeInPeopleCount && ![self.model2.safeInPeopleCount isEqualToString:@""] && self.model2.safeProActualcount && ![self.model2.safeProActualcount isEqualToString:@""]) {
                    
                    double rate = [self.model2.safeInPeopleCount doubleValue] / [self.model2.safeProActualcount doubleValue];
                   
                    self.model2.safeCoincidenceRate = [NSString stringWithFormat:@"%.2f", rate];
                    NSString *str = [NSString stringWithFormat:@"%.2f%%", rate*100];
                    weakCell2.coincidenceRateLabel2.text =  DEFISNUL(str);
                }
            };
            
            // 符合人数(安全员)
            threeCell2.complyNumberField.text = DEFISNUL(self.model2.safeInPeopleCount);
            threeCell2.complyNumberBlock = ^(NSString *str) {
                self.model2.safeInPeopleCount = str;
                
                // 更新符合率
                if (self.model2.safeInPeopleCount && ![self.model2.safeInPeopleCount isEqualToString:@""] && self.model2.safeProActualcount && ![self.model2.safeProActualcount isEqualToString:@""]) {
                    
                    double rate = [self.model2.safeInPeopleCount doubleValue] / [self.model2.safeProActualcount doubleValue];
                    self.model2.safeCoincidenceRate = [NSString stringWithFormat:@"%.2f", rate];
                    NSString *str = [NSString stringWithFormat:@"%.2f%%", rate*100];
                    weakCell2.coincidenceRateLabel2.text =  DEFISNUL(str);
                }
            };
            
            // 符合率
            if (!self.model2.safeCoincidenceRate) {
                self.model2.safeCoincidenceRate = @"0";
            }
            
            double rate = [self.model2.safeCoincidenceRate doubleValue];
            NSString *str = [NSString stringWithFormat:@"%.2f%%", rate*100];
            threeCell2.coincidenceRateLabel2.text = DEFISNUL(str);
            

            // 配备符合要求
            // 默认为1
            if (!self.model2.safeIsMeetRequire) {
                self.model2.safeIsMeetRequire = @"1";
            }
            if ([self.model2.safeIsMeetRequire isEqualToString:@"1"]) {
                threeCell2.meetRequireSwitch.on = YES;
                
            } else {
                threeCell2.meetRequireSwitch.on = NO;
            }
            threeCell2.meetRequireBlock = ^(NSString *str) {
                self.model2.safeIsMeetRequire = str;
            };
        }
        return threeCell2;
    }
}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end

